'''
# Coding:utf-8
# Project: python-utility
# Author: rtf
# Time: 2022-09-27 09:32:55
# FileName: system_spec.py
# Software: PyCharm
'''

# 图像转换为素描
import cv2

# 读取图片
img = cv2.imread("images/1.jpg")
# 灰度
grey = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
invert = cv2.bitwise_not(grey)
# 高斯滤波
blur_img = cv2.GaussianBlur(invert, (7, 7), 0)
inverse_blur = cv2.bitwise_not(blur_img)
sketch_img = cv2.divide(grey, inverse_blur, scale=256.0)
# 保存
cv2.imwrite('images/sketch.jpg', sketch_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
